<?php

class zShang_Controller_Action extends Zend_Controller_Action {

    public function preDispatch() {
//        $auth = Zend_Auth::getInstance();
//        if (!$auth->hasIdentity()) {
//            if ($this->_request->getActionName() != 'login') {
//                $this->_redirect('/index/login');
//            }
//        }
    }

    public function init() {
        parent::init();
        $this->_authorize();        
    }

    /**
     *
     */
    public function _authorize() {
        // ACL
        $registry = Zend_Registry::getInstance();
        $acl = $registry->get('acl');

        // Current resource
        $modules = $this->_request->getModuleName();
        $controller = $this->_request->getControllerName();
        $action = $this->_request->getActionName();
        
        if ($modules == 'front') {
              $this->_helper->layout->setLayout('layout_front');
        }
        // Check
        $role = NULL;
        $resource = $modules . ':' . $controller;
        $session = $registry->get('session');

        if (empty($session->username)) {
            // Redirect to login page
        } else {
            
        }
    }

}